(()=> {
	let ele = {};
	ele.listBox = $('#listBox');
	ele.empty = $('#empty');
	ele.more = $('#more');
	
	
	let page = 1;
	
	getPastRecords(page)
	// 获取往期记录 列表
	function getPastRecords(page) {
		let token = getCookie("token");
		ajax({
			url: API_PATH.GET_PAST_RECORDS,
			method: 'get',
			header: {
				'Authorization': token,
			},
			data: {
				page: page
			},
			success: res => {
				if (res.code == 1) {
					let detail = res.data.list.data;
					if (detail.length === 0) {
						page = 0;
						ele.more.style.display = "none";
						ele.empty.style.display = "flex";
					} else {
						drawDetail(detail);
						page++;
						if (page > res.data.list.last_page) {
							ele.more.innerText = '没有更多了';
							ele.more.onclick = null;
						}
						else {
							ele.more.innerText = '加载更多';
							ele.more.onclick = () => getPastRecords(page);
						}
					}
					// for(let i = 0; i < _data.length; i++) {
					// 	if(_data[i].status == 1) {
					// 		ring_id = _data[i].id
					// 		// ele.riqi.innerHTML = _data[i].phase
					// 		getFinaListRecords(ring_id)
					// 	}
					// }
				} else openTips(res.msg || '未知错误');
			}
		});
	}
	
	
	function drawDetail(data) {
		if (data.length === 0) {
			page = 0;
			ele.more.style.display = "none";
			ele.empty.style.display = "flex";
		} else {
			let str = '';
			let headerimg = ''
			for (let i = 0; i < data.length; i++) {
				if(data[i].head_pic == '' || data[i].head_pic == null) {
				    if(data[i].sex == 1) {
				        headerimg = 'http://img.qxgs.cc/tiantianlaishouzu/img/my/tx1.png'
				    }else {
				        headerimg = 'http://img.qxgs.cc/tiantianlaishouzu/img/my/tx2.png'
				    }
				}else {
				    headerimg = IMG_DOMAIN + data[i].head_pic
				}
				str +=`<div class="list">
							<div class="top">${data[i].phase}-擂台霸主</div>
							<div class="item">
								<div class="left">
									<img src="${headerimg}" alt="">
									<div class="itemin">
										<span>${data[i].nick_name}</span>
										<p>房间人数 <span>${data[i].house_num}/40</span></p>
									</div>
								</div>
								<div class="right">
									<p>房产名字编号:<span>${data[i].house_code}</span> </p>
									<p>团队豪华值:<span>${data[i].luxury}</span> </p>
								</div>
							</div>
						</div>`;
			}
			ele.listBox.innerHTML += str;
		}
	}
})()